package main

import (
	"fmt"
)

func main()  {
	//new 和 make
	//d := [10]int{}
	//log.Printf("%p - %v - %T \n",d,d,d)
	//n := new([10]int) //长度
	//log.Printf("%p - %v - %T \n",n,n,n)
	//m := make([]int,5,10) //类型，长度，容量
	//log.Printf("%p - %v - %T \n",m,m,m)
	//m2 := new([]int)
	//log.Printf("%p - %v - %T \n",m2,m2,m2)
	//return

	//var balance = [...]float32{1000.0, 2.0, 3.4, 7.0, 50.0}
	//fmt.Println(balance)
	//fmt.Printf("%v - %T \n", balance, balance)
	//
	//s :=[] int {1,2,3 }
	//fmt.Println(s)
	//fmt.Printf("%v - %T \n", s, s)
	//
	//var balance2 = []float32{1000.0, 2.0, 3.4, 7.0, 50.0}
	//fmt.Println(balance2)
	//fmt.Printf("%v - %T \n", balance2, balance2)


	//给数组生成切片
	var array = [...]int {1,2,3,4,5,6}
	split := array[0:]
	fmt.Println("原生切片================")
	fmt.Println(array)
	fmt.Println(split,"cap",cap(split),"len",len(split))
	fmt.Printf("内存地址%p - %p \n", &array, split)

	fmt.Println("修改原数组================")
	array[5] = 0
	fmt.Println(array)
	fmt.Println(split,"cap",cap(split),"len",len(split))
	fmt.Printf("内存地址%p - %p \n", &array, split)


	fmt.Println("扩容切片================")
	split = append(split,12)
	fmt.Println(array)
	fmt.Println(split,"cap",cap(split),"len",len(split))
	fmt.Printf("内存地址%p - %p \n", &array, split)

	fmt.Println("扩容后再修改数组================")
	array[4] = 0
	fmt.Println(array)
	fmt.Println(split,"cap",cap(split),"len",len(split))
	fmt.Printf("内存地址%p - %p \n", &array, split)

	fmt.Println("切片移动================")
	split2 := split[3:]
	fmt.Printf("内存地址%p - %p \n", split2, split)

}
